package met.cs664.ai.cox.soc.strategies.placement;

import soc.game.SOCBoard;

import java.util.List;


/**
 * Scores potential placements on the probability of its adjacent hexes producing resources based on their die roll values.
 *
 * @author mcox
 */
public class ResourceProbability extends AbstractEvaluator implements PlacementEvaluator {

    /**
     * Maps die roll number to their dot (probability) value when rolled on 2 6-sided die. Dots is a SOC concept and
     * are present on the board game number pieces, but in general represent the probability of a particular number
     * being rolled. Represented here as 0-12. 0 & 1 are impossible, and seven is the robber and scores no resources.
     */
    public static final int [] DOT_VALUE = new int [] {0, 0, 1, 2, 3, 4, 5, 0, 5, 4, 3, 2, 1};

    public ResourceProbability(float weight) {
        super(weight);
    }

    public String toString() {
        return "ResourceProbability";
    }

    @Override
    public void evaluateCandidates(SOCBoard board, List<PlacementCandidate> candidates) {
        for (PlacementCandidate candidate : candidates) {
            int score = 0;
            for (int hexCoord : getAdjacentHexesToNode(candidate.getCoord())) {
                score += DOT_VALUE[board.getNumberOnHexFromCoord(hexCoord)];
            }

            candidate.updateWeight(getWeight() * score);
        }
    }
}
